Skip to content

Conversation

rwrozelle
Copy link
Contributor

@rwrozelle rwrozelle commented Feb 28, 2025

ESPHome PR esphome/esphome#9294

Extends the media_player to additional features. supports_turn_off_on

Dependent on PR: #1285

Copy link
Contributor

coderabbitai bot commented Feb 28, 2025

## Walkthrough

The changes update the protocol buffer definitions and Python model for media player functionality by adding three new states and nine new commands to the `MediaPlayerState` and `MediaPlayerCommand` enums. The `ListEntitiesMediaPlayerResponse` message adds a new `feature_flags` field. The Python `MediaPlayerInfo` dataclass gains a `feature_flags` attribute and a compatibility method for API versions. Tests were added to verify feature flag compatibility.

## Changes

| Cohort / File(s)                | Change Summary                                                                                                                  |
|--------------------------------|---------------------------------------------------------------------------------------------------------------------------------|
| **Protocol Buffers**<br>`aioesphomeapi/api.proto` | Extended `MediaPlayerState` and `MediaPlayerCommand` enums with new values; added `feature_flags` field to `ListEntitiesMediaPlayerResponse`. |
| **Model Definitions**<br>`aioesphomeapi/model.py`  | Added `MediaPlayerEntityFeature` IntFlag enum; extended `MediaPlayerState` and `MediaPlayerCommand` enums; added `feature_flags` attribute and `feature_flags_compat` method to `MediaPlayerInfo`. |
| **Tests**<br>`tests/test_model.py`     | Updated test to include `feature_flags` in media player info; added test for `feature_flags_compat` method verifying compatibility across API versions. |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant Client
    participant API
    participant MediaPlayer

    Client->>API: ListEntitiesMediaPlayer
    API->>MediaPlayer: Query media player capabilities and state
    MediaPlayer-->>API: States, commands, feature_flags
    API-->>Client: ListEntitiesMediaPlayerResponse (with updated states, commands, feature_flags)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes


Suggested labels: `new-feature`

<!-- walkthrough_end -->

<!-- announcements_start -->

> [!NOTE]
> <details open="true">
> <summary>⚡️ Unit Test Generation is now available in beta!</summary>
> 
> Learn more [here](https://docs.coderabbit.ai/finishing-touches/unit-test-generation), or try it out under "Finishing Touches" below.
> 
> </details>

<!-- announcements_end -->

---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between a07610c6045e1564871092bc05882d14888ba55c and fed8281d8fe89b4d649d5a7fcf31f69c29f5b3df.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `aioesphomeapi/model.py` (3 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* aioesphomeapi/model.py

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACI2Wng0AH1uLzRZSnRaenwAMxz+LAY0bhV4L3VZaMgAdzRkBwFmdRp6OTDYD2xEDIpqinwALxIfD0x6VHglDHEc+Ci6yAxHAQyARgAGAE4AJg1IAElQoqwV9AYGaW76anaPHPwffGr4DCJIAFUbABkuWFxcbiIDgAemBRHUsGwAg0TGYwOk3FgLBIwO0+ARSLYxXgwO43i8wI2Ow0bg6kCUiAYFHg3HE+CwuVunh8fkCwUQoQ51Gk7Ru6kgJAAHjQMLRkLgyXEEslUuk+LDuPT2GF8Jl4nSMGhfDkSNRsP5EAAaezcUTwWZFHzyNBZF5vBzcRUUUL3Pi4fUYO1MqVoHiyjK5fJjAqQAAUDqduEQiXdFAwiUDCYwAEoSQYLJAAMIsNjTeqOZjOVwGADKJCkVF8sNzUZqlA8haUIYlHjxLP8QRCkDa8Ty9emkC6lCNkHuDC6Xt48EL1K88npCnwFHimo16FFPH6F0QyCoLbdsEwYVEsE9lvJJFw2i8iDT+094i1c+NAloVCY9mwRFIHKiDC8+CIF6wb+Pgpqeq8TJtr4HbsqEBCslyzpMkw0wvNg+BdCg0wkEQe7wAuoaZvsyabvg27iqqNpvpcKA7uyrKpC0KoKGK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wH7LqM8/K3s3QLQKsLM7QFK/nNayS3cxsEoLU4VjkOi+KzK49LqwXHUzs02j83s49PnK04y8C6sOUyoPnG42gIUxsOsCs4s/434+sP4wIIk4JJsOa1AJsC0+0wcyPDC6iyswMzS200M7E1M5sJC09I0w0+sIS1U7dNm+gDK009sKPCS9sxE4W81U0wcyM40z0xU4k37MPCc821ix7NayQD07U+U4S3QB26i/49Cwm24+E2syQKmyPIU/nJE2k1O2Ew2/q9C/a0k6PKk146sGgHy7UzXWU0EyG8O6E+cy2w9IJIU7EwsyC2gJC80/M+M0BwwLmw8yGk9Dc0UCE9sC29U2ExcwIA2w0yPCk7dFa2U2gAa17KPOc9G/nG60S6sCGpiwGyo/nK+NsH7MkyhxM7O8c8q/nHc2gGgJsB84x7QGcyQDK7ax+5sCRxk3s0U0E7dEM9uxM81bC7R106E+SysK+IVrkxM+K+SzsPkFOwp5SwlAXNE5sK66S7qAm105U7WxcBXAlLpzkE9AwAcwbFO/h9S/S+mzCxM50yGjk+sDKyC3E89Ch4TjK64/U8iy217J06G2c9sIc1UwwKPJZyQBR1sGi8C8x5R803Uyc4Vi2wwB+97NMwM40y8/hxqzkO2/cwp0634wK5SwIHkPly2x690x8wwPS1y/U5E9a4s8i1CyGm6x+9C+6x+342gPx4G1ALe0CxsAwJ5yh8q8C/h0SBF6U4Wy81a5K+R5hwKy2+8wV6sLazqFK+mxxw9Kx0k26xc/85Zxy6S6EwIGh2pwGyNy6qVFY2KIkLY7grQIkBmi28wAwNwIdThMKA484E4/d7emDwYAAN4GCQAxAszwDcJRjRBcAADaAAuoaNDzELUHGNxEj5AGjwYAAL4GBg8x4Pc/d/eoQ0CA9ff6BAA= -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details>
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings
<details>
<summary>🧪 Generate unit tests</summary>

- [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Create PR with unit tests
- [ ] <!-- {"checkboxId": "07f1e7d6-8a8e-4e23-9900-8731c2c87f58", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} -->   Post copyable unit tests in a comment

</details>

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

<details>
<summary>❤️ Share</summary>

- [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai)
- [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai)
- [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai)
- [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

</details>

<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=esphome/aioesphomeapi&utm_content=1092):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai generate unit tests` to generate unit tests for this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

Copy link

codspeed-hq bot commented Feb 28, 2025

CodSpeed Performance Report

Merging #1092 will not alter performance

Comparing rwrozelle:media_player_all_features (eab4666) with main (69d12cf)1

Summary

✅ 11 untouched benchmarks

Footnotes

  1. No successful run was found on main (33910f9) during the generation of this report, so 69d12cf was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (69d12cf) to head (eab4666).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1092   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           20        20           
  Lines         3028      3032    +4     
=========================================
+ Hits          3028      3032    +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d803269 and b8abce2.

📒 Files selected for processing (3)
  • aioesphomeapi/api.proto (4 hunks)
  • aioesphomeapi/client.py (2 hunks)
  • aioesphomeapi/model.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**`: - Do not generate or add any sequence diagrams

**: - Do not generate or add any sequence diagrams

  • aioesphomeapi/client.py
  • aioesphomeapi/api.proto
  • aioesphomeapi/model.py
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: py 3.12 on windows-latest (skip_cython)
🔇 Additional comments (8)
aioesphomeapi/client.py (1)

1232-1260: New media player command parameters look good.

The additions of enqueue and group_members parameters to the media_player_command method are well-implemented, with proper optional typing and conditional flag setting. The implementation follows the same pattern as the existing parameters.

aioesphomeapi/api.proto (4)

1127-1159: Media player state and command enums expanded appropriately.

The new states and commands enhance the media player functionality as described in the PR objectives, adding support for announcements, power control, track navigation and playback controls.


1190-1193: Support flags for new media player capabilities.

The new boolean capability flags correctly implement the planned functionality additions: turning media players on/off, grouping players together, and navigating between tracks.


1203-1210: Enhanced media player state attributes.

The additional fields for song metadata and playback state provide much more detailed information about currently playing media, which will greatly improve the user experience.


1231-1236: Command request fields for new functionality.

The enqueue and group_members fields enable the new features and follow the same pattern as existing command parameters with appropriate has_* flags.

aioesphomeapi/model.py (3)

813-816: Media player state enum values correctly added.

The new state enum values match the protocol definitions and enable the new functionality.


872-875: Media player info capability flags properly added.

These flags correctly correspond to the new fields in the ListEntitiesMediaPlayerResponse message.


891-899: Media player state information significantly enhanced.

The new attributes in MediaPlayerEntityState provide rich metadata about media playback, matching the protocol definition.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
aioesphomeapi/model.py (2)

873-875: Consider renaming for clarity.

supports_turn_off_on might be more consistent if named supports_turn_on_off or supports_power_toggle to match reading order and be more descriptive. This is a minor naming nitpick but can improve clarity.


891-899: Consider using strong types for repeat/shuffle/timing fields.

Storing repeat as a string and duration/position as integers can work, but using dedicated enums (for repeat/shuffle) or floats (for more precise timing) can improve type safety and clarity. Otherwise, please ensure robust validation for string-based repeat values.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8abce2 and 18436fa.

📒 Files selected for processing (1)
  • aioesphomeapi/model.py (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**`: - Do not generate or add any sequence diagrams

**: - Do not generate or add any sequence diagrams

  • aioesphomeapi/model.py
🔇 Additional comments (2)
aioesphomeapi/model.py (2)

814-816: Check for feature usage of newly introduced states.

These new states (OFF, ON, and ANNOUNCING) appear valid. Please ensure they are handled throughout the codebase wherever a media player state might be set or interpreted, so that existing code that expects only IDLE, PLAYING, or PAUSED does not encounter unexpected behavior.


825-840: All new commands are well-structured and consistent.

Thank you for fixing the previous tuple-related syntax. These commands integrate well with the existing MediaPlayerCommand pattern.

@bdraco bdraco added the waiting-for-esphome Indicates the PR is waiting for the esphome main repo code approval label Feb 28, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
aioesphomeapi/client.py (1)

1231-1262: Consider adding documentation for the new parameters

The method lacks docstring documentation explaining what the new parameters do. Adding documentation would improve developer experience and code maintenance.

 def media_player_command(
     self,
     key: int,
     *,
     command: MediaPlayerCommand | None = None,
     volume: float | None = None,
     media_url: str | None = None,
     announcement: bool | None = None,
     enqueue: str | None = None,
     group_members: str | None = None,
 ) -> None:
+    """Send a command to a media player.
+
+    Args:
+        key: The key identifying the media player.
+        command: The command to send to the media player.
+        volume: The volume to set on the media player.
+        media_url: The URL of media to play.
+        announcement: Whether this is an announcement.
+        enqueue: The enqueue option for the media player.
+        group_members: The group members for the media player when operating in group mode.
+    """
     req = MediaPlayerCommandRequest(key=key)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 15b2705 and 35316b7.

📒 Files selected for processing (1)
  • aioesphomeapi/client.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**`: - Do not generate or add any sequence diagrams

**: - Do not generate or add any sequence diagrams

  • aioesphomeapi/client.py
🔇 Additional comments (2)
aioesphomeapi/client.py (2)

1239-1240: Method signature enhancement for extended media player functionality

The addition of enqueue and group_members parameters aligns well with the PR objectives, enabling support for the media player enqueueing functionality and grouping capabilities.


1255-1260: Implementation follows consistent parameter handling pattern

The implementation for the new parameters follows the established pattern in the codebase, properly checking for None values before setting the request attributes and their corresponding flags.

@bdraco bdraco closed this Apr 14, 2025
@bdraco bdraco reopened this Apr 14, 2025
@bdraco
Copy link
Member

bdraco commented Apr 14, 2025

close/reopen to restart CI to fix codspeed settings

@rwrozelle rwrozelle changed the title media_player_all_features media_player add off on capability Apr 15, 2025
@bdraco
Copy link
Member

bdraco commented Apr 29, 2025

Is there a PR on the main ESPhome repo to accompany this PR? If so please link it in the opening text as we need that one to be approved before this can merge

@rwrozelle
Copy link
Contributor Author

I have the code, but have not sent in a PR for it, I will work on that.

@bdraco
Copy link
Member

bdraco commented Jul 29, 2025

@rwrozelle please resolve conflicts. Thanks

@rwrozelle
Copy link
Contributor Author

MediaPlayerInfo.feature_flags_compat will not return the value from feature_flags set by esphome until API 1.11 is released.

@bdraco bdraco merged commit af83313 into esphome:main Jul 30, 2025
15 checks passed
@bdraco bdraco removed the waiting-for-esphome Indicates the PR is waiting for the esphome main repo code approval label Jul 30, 2025
@bdraco
Copy link
Member

bdraco commented Jul 30, 2025

Probably should have bumped the minor version but not a big deal

@rwrozelle rwrozelle deleted the media_player_all_features branch July 30, 2025 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants